package com.sk.cardeal.act.home.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sk.cardeal.R;
import com.sk.cardeal.adapter.PartsAdapter;
import com.sk.cardeal.adapter.WorkPostionAdapter;
import com.sk.cardeal.base.BaseActivity;
import com.sk.cardeal.entity.WorkPostion;
import com.sk.cardeal.view.TitleView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by sk on 2018/1/16.
 */

public class ChooseWorkPostionActivity extends BaseActivity implements BaseQuickAdapter.OnItemClickListener {


    @BindView(R.id.title_view)
    TitleView titleView;
    @BindView(R.id.data_ryc)
    RecyclerView dataRyc;
    private WorkPostionAdapter adapter;

    private List<WorkPostion> workPostionList = new ArrayList<>();

    @Override
    protected int getContentView() {
        return R.layout.activity_work_pos;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        titleView.setMyCallBack(this);
        workPostionList = getIntent().getParcelableArrayListExtra("data");

        dataRyc.setLayoutManager(new LinearLayoutManager(mContext));
        adapter = new WorkPostionAdapter(R.layout.item_worker_pos, workPostionList);
        dataRyc.setAdapter(adapter);
        adapter.setOnItemClickListener(this);
    }

    @Override
    public void clickTitle(int i) {
        super.clickTitle(i);
        switch (i) {
            case 1:
                finish();
                break;
        }
    }


    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        Intent intent = new Intent();
        intent.putExtra("data", workPostionList.get(position));
        setResult(RESULT_OK, intent);
        finish();
    }
}
